<?php
class addlinkAction extends security_normal {
	
	function action(){
		$miceSession = new session();	
		if($miceSession->get('mu__userid')<1)
		{
			$uid=0;
			$name='';
		}
		else
		{
			$uid=$miceSession->get('mu__userid');
			$name=$miceSession->get('mu__loginname');
		}
		global $conn;
		if($_POST){
			if($_POST['checkcode']<>$miceSession->get('checkcode')){
				MessageBox('验证码错误','back');
				exit;
			}

			if($_POST['name']==''){
				MessageBox('请填写姓名','back');
				exit;
			}

			if($_POST['title']==''){
				MessageBox('请填写标题','back');
				exit;
			}

			$content='网站名称：'.$_POST['title'].'<br>网址：'.$_POST['url'].'<br>logo：'.$_POST['logo'].'<br>网站简介：'.MiceFilterQuote($_POST['content']);

			$form=new model_Form();
			$form->setName($_POST['name']);
			$form->setUserId($uid);
			$form->setEmail($_POST['email']);
			$form->setTitle(MiceFilterHtml($_POST['title']));
			$form->setCreatedat(time());
			$form->setType('link');
			$form->setIp(GetRealIp());
			$form->setContent($content);
			$results=$form->doInsert();

			if($results)
				$exeresult='提交成功';
			else
				$exeresult='提交失败';
			MessageBox($exeresult,MICE_URL);
			exit;
		}

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign("name",$name);
		$smarty->assign("checkcode",MICE_URL.'code.php');

		$filename = new getTPLFileName(__CLASS__);
		$tpl=$filename->TPLFileName;
		$smarty->display($tpl);
	}	
}
?>